<?php
	
    include_once($_SERVER['DOCUMENT_ROOT']."/BT32/database/database.php");

    class NguoiDung extends database{
    	private $magv;
    	private $matkhau;
    	private $quyen;

    	public function setmagv($magv){
    		$this->magv = $magv;
    	}

    	public function getmagv(){
    		return $this->magv;
    	}

    	public function setmatkhau($matkhau){
    		$this->matkhau = $matkhau;
    	}

    	public function getmatkhau(){
    		return $this->matkhau;
    	}

    	public function setquyen($quyen){
    		$this->quyen = $quyen;
    	}

    	public function (){
    		return $this->quyen;
    	}

    	public function kiemtra(){
    		return $this->isExits("NguoiDung", "magv='". $this->getmagv() . "' and matkhau = '" . $this->getmatkhau() . "'");
    	}

    	public function xoanguoidung(){
    		$this->setQuery("delete from NguoiDung where magv = '" . $this->getmagv() . "'");
    		return $this->executeQuery();
    	}

    	public function themnguoidung(){
    		$this->setQuery("insert into NguoiDung(magv, matkhau, quyen) values ('".$this->getmagv()."','".$this->getmatkhau()."','".$this->getquyen()."')");
    		return $this->executeQuery();
    	}

    	public function suanguoidung(){
    		$this->setQuery("update NguoiDung set matkhau='".$this->getmatkhau()."', quyen='".$this->getquyen()."' where magv='".$this->getmagv()."'");
    		return $this->executeQuery();
    	}

    	public function ganquyen(){
    		if ($this->kiemTra()!=0){
                while ($rows = mysql_fetch_array($this->getResult())){
                    $this->setquyen($rows['quyen']);               
               } 
            }
    	}

    	public function dsnguoidung(){
    		$query = "select distinct (c.magv) as magv, c.matkhau as matkhau, c.quyen as quyen, d.tengv as tengv from NguoiDung c, llgv d ";
    		$query .= " where c.magv = d.magv ";
    		$this->setQuery($query);
            return $this->fetchAll();
    	}
    }
?>